Skip to content

[WebGPU-XR] Check XRGPUBinding before native fallback - #18711

Merged
sebavan merged 1 commit into
BabylonJS:masterfrom
rebeckerspecialties:codex/webxr-layers-capability-order
Jul 21, 2026
Merged

[WebGPU-XR] Check XRGPUBinding before native fallback#18711
sebavan merged 1 commit into
BabylonJS:masterfrom
rebeckerspecialties:codex/webxr-layers-capability-order

Conversation

@matthargett

Copy link
Copy Markdown
Contributor

Background

Broader WebGPU runtime testing showed that WebXRLayers.isCompatible() rejects every native session before checking the active engine and XRGPUBinding capabilities. A standards-compatible WebGPU runtime can therefore expose XRGPUBinding.createProjectionLayer and still be prevented from selecting the existing WebGPU projection-layer path.

Change

  • Check WebGPU and XRGPUBinding.createProjectionLayer before the native WebGL fallback.
  • Keep native WebGL sessions on the existing NativeXRRenderTarget path.
  • Preserve browser WebGPU and WebGL behavior.
  • Make no public API changes.

Tests

Adds five explicit compatibility cases:

  • native WebGPU with projection-layer support
  • native WebGPU without XRGPUBinding
  • native WebGL with XRWebGLBinding
  • browser WebGPU with projection-layer support
  • browser WebGL with projection-layer support

Local validation:

  • focused fixture: 5/5 tests passed
  • XR unit suite: 280/280 tests passed across 16 files
  • exact-file ESLint and Prettier checks passed
  • production core TypeScript build passed

Relation to #18688

cc @RaananW. This is intentionally separate from #18688: this PR makes the WebGPU layer provider reachable when the runtime advertises the required capability, while #18688 addresses projection/NDC and upright rendering after that layer path is active. The changes do not overlap files.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts WebXRLayers.isCompatible() so native sessions are not rejected before checking whether the active engine is WebGPU and whether XRGPUBinding supports projection layers. This makes the WebGPU projection-layer path reachable on native runtimes that correctly advertise XRGPUBinding.createProjectionLayer, while keeping native WebGL on the existing legacy NativeXRRenderTarget path and preserving browser behavior.

Changes:

  • Reorders compatibility checks to evaluate WebGPU + XRGPUBinding.createProjectionLayer before the native WebGL fallback.
  • Keeps native WebGL sessions explicitly incompatible with WebXR Layers (legacy path unchanged).
  • Adds unit tests covering 5 compatibility permutations across native/browser and WebGPU/WebGL.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/dev/core/src/XR/features/WebXRLayers.pure.ts Reorders isCompatible() checks to allow native WebGPU projection-layer support while retaining native WebGL fallback behavior.
packages/dev/core/test/unit/XR/webXRLayers.test.ts Adds focused Vitest coverage for the compatibility matrix (native/browser × WebGPU/WebGL × binding availability).

@RaananW

RaananW commented Jul 20, 2026

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@RaananW

RaananW commented Jul 20, 2026

Copy link
Copy Markdown
Member

I will actually ask someone from the native team to review that, because there is a reason why it is there. @bghgary @CedricGuillemet , any input here?

@bjsplat

bjsplat commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat

bjsplat commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Snapshot stored with reference name:
refs/pull/18711/merge

Test environment:
https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/18711/merge/index.html

To test a playground add it to the URL, for example:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/18711/merge/index.html#WGZLGJ#4600

Links to test your changes to core in the published versions of the Babylon tools (does not contain changes you made to the tools themselves):

https://playground.babylonjs.com/?snapshot=refs/pull/18711/merge
https://sandbox.babylonjs.com/?snapshot=refs/pull/18711/merge
https://gui.babylonjs.com/?snapshot=refs/pull/18711/merge
https://nme.babylonjs.com/?snapshot=refs/pull/18711/merge

To test the snapshot in the playground with a playground ID add it after the snapshot query string:

https://playground.babylonjs.com/?snapshot=refs/pull/18711/merge#BCU1XR#0

If you made changes to the sandbox or playground in this PR, additional comments will be generated soon containing links to the dev versions of those tools.

@bjsplat

bjsplat commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

⚡ Performance Test Results

🟢 All performance tests passed — no regressions detected.

@bjsplat

bjsplat commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

@bjsplat

bjsplat commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

🟢 Memory Leak Test Results

4 passed, 0 leaked out of 4 scenarios

🟢 All memory leak tests passed — no leaks detected.

Passed Scenarios (4)
Scenario Package
Core Playground #2FDQT5#1508 @babylonjs/core
Core Playground #T90MQ4#14 @babylonjs/core
Core Playground #8EDB5N#2 @babylonjs/core
Core Playground #LL5BIQ#636 @babylonjs/core

@bjsplat

bjsplat commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

@bjsplat

bjsplat commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

@RaananW RaananW left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will merge after the native team give me the OK.

Comment thread packages/dev/core/src/XR/features/WebXRLayers.pure.ts

@CedricGuillemet CedricGuillemet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure of all the implications this will have with native webgpu support but I guess it's fine for now.

@sebavan
sebavan merged commit 4f6c7b2 into BabylonJS:master Jul 21, 2026
21 checks passed
@matthargett

Copy link
Copy Markdown
Contributor Author

I'm not sure of all the implications this will have with native webgpu support but I guess it's fine for now.

FWIW, I'm testing with my wgpu branch in addition to the other scenarios :)

@matthargett
matthargett deleted the codex/webxr-layers-capability-order branch July 26, 2026 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants